package com.mobile.web.control;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;

import com.google.common.collect.Maps;
import com.mobile.common.base.web.BaseController;
import com.mobile.handler.UserPurviewHandler;
import com.mobile.persistent.entity.Users;

@Controller
@Scope("prototype")
@RequestMapping("/index")
public class IndexController extends BaseController {

	@Resource private UserPurviewHandler userPurviewHandler;
	
	@RequestMapping
	public ModelAndView index(
            final HttpServletRequest request,
            final HttpServletResponse response){
		Map<String, Object> dataMap = Maps.newHashMap();
		Users user = (Users)WebUtils.getSessionAttribute(request, "LoginUser");
		
		dataMap.put("operCode", userPurviewHandler.getOperCode(user.getId()));
		return new ModelAndView("/main/main.jsp", dataMap);
	}
}
